﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using UMS.DataModelLayer;
using UMS.TransportLayer;
using System.Net;

namespace UMS.Essences
{
    public abstract class Connection
    {
        public string Name { get; set; }
    }
    public class ICQConnection : Connection
    {
        public string UIN
        {
            get
            {
                return new String(uin);
            }
            set
            {
                Regex r = new Regex("^\\d{9}$");
                if (r.Match(value).Success == true)
                    uin = value.ToCharArray();
                else
                    throw new FormatException("Wrong ICQ UIN!");
            }
        }
        char[] uin = new char[9];
    }
    public class UMSConnection : Connection
    {
        public UIN Number { get; set; }
        public List<HostAddress> GlobalAddresses { get { return addrs; } }
        List<HostAddress> addrs;

        public UMSConnection(UIN n)
        {
            Number = n;
            IPAddress ip = ExternalIP.GetExternalIP();
            addrs.Add(new HostAddress(ip));
        }
    }
}
